using Assets.Framework.WooEngineExtends.Config;
using PureMVC.Interfaces;
using System;
using UnityEngine;
using WooEngine.Common;
using WooEngine.ConfigWork;
using WooEngine.Res;

public class InitDefaultCommand : AbstractSimpleCommand
{
    public const string DefaultClassName = "InitDefaultCommand";
    public override void Execute(INotification notification)
    {
        base.Execute(notification);

        AppConfigProxy proxy = (AppConfigProxy)Facade.RetrieveProxy(AppConfigProxy.DefaultName);

        if(proxy.Lang() < 0)
        {
            proxy.SetLang(0);
        }
        LangManager.Instance.InitLang(proxy.Lang(), loadCHS);
    }


    private void loadCHS()
    {
        ResourceManager.Instance.LoadAssetAsync<TextAsset>("init_info", loadOver);
    }

    private void loadOver(TextAsset textAsset, object arg2)
    {
        ConfigManager.Instance.AddFile(textAsset);
        ResourceManager.Instance.ReleaseAsset(textAsset);

        InitProto.Instance.LoadData();
        CodeProto.Instance.LoadData();

        SendNotification(CSNetGateWayGetCenterInfoCommand.DefaultClassName);
    }
}
